package com.ibm.dtp.ejb.crud;

import java.util.ArrayList;
import java.util.List;

public class DynamicQueryParameter {
	private List<ParameterDefinition> parameters = null;

	private DynamicQueryParameter(String name, Object value) {
		this.parameters = new ArrayList<ParameterDefinition>();
		addParameter(ParameterType.WITH, name, value);
	}

	public static DynamicQueryParameter with(String name, final Object value) {
		return new DynamicQueryParameter(name, value);
	}

	public DynamicQueryParameter and(String name, final Object value) {
		addParameter(ParameterType.AND, name, value);

		return this;
	}

	public DynamicQueryParameter or(String name, final Object value) {
		addParameter(ParameterType.OR, name, value);

		return this;
	}

	public List<ParameterDefinition> parameters() {
		return this.parameters;
	}

	private void addParameter(ParameterType paramType, String name,
			final Object value) {
		parameters.add(new ParameterDefinition(paramType, name, value));
	}
}